﻿@{
    ViewBag.Title = ViewBag.Year + "年" + ViewBag.Month + "月随笔归档 - " + ViewBag.User.UserName;
}
@section styles{
    @Styles.Render("~/content/default")
}
<div class="hx-container blog-view">
    <div class="d-flex">
        @{
            Html.RenderPartial("side", ViewBag.User as HxBlogs.Model.UserInfo);
        }
        <article class="flex-fill overflow-hidden">
            <div class="mt-2 ml-2 py-3 px-3 bg-white">
                <span>
                    <a target="_blank" href="@WebHelper.GetFullUrl(ViewBag.User.UserName)">全部文章</a>
                </span>
                <span>&nbsp;&nbsp;>&nbsp;&nbsp;</span>
                <span>@(ViewBag.Year + "年" + ViewBag.Month + "月")</span>
            </div>
            <div class="mt-2 ml-2 bg-white partial-content" data-url="/article/@ViewBag.User.UserName/archivearticle/@ViewBag.Year/@ViewBag.Month" hidden>
            </div>
        </article>
    </div>
</div>
@section scripts{
    <script type="text/javascript">
        $(function () {
            loadPartial();
            $(".partial-content").on('click', '.hx-a', function () {
                var $me = $(this),
                    id = $me.data('id'),
                    url = $me.data('url');
                if (hxCore.isEmpty(url)) return;
                alertify.confirm(`确定要${$me.text()}当前文章?`, function () {
                    hxCore.ajax(url, {
                        data: {
                            id: id
                        },
                        success(data) {
                            loadPartial();
                            hxCore.remindSuccess(data);
                        }
                    });
                });
            });
        });
        function loadPartial() {
            $(".partial-content").each(function (index, item) {
                var url = $(item).data("url");
                if (url && url.length > 0) {
                    $(item).load(url, function (response, status, xhr) {
                        if (status == 'success') {
                            $(this).removeAttr('hidden');
                        } else {
                            hxCore.ajaxError(xhr);
                        }
                    });
                }
            })
        }
    </script>
}
